﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Text;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using com.tiyma.model;
using com.tiyma.components;
using com.tiyma.common;

namespace com.tiyma.web.book
{
    public partial class ChapterList : BasePage
    {
        public string m_book_name = string.Empty;
        public string m_author_name = string.Empty;
        public string m_description = string.Empty;
        public string m_chapter_list = string.Empty;
        public string m_site_name = string.Empty;
        public string m_chapter_list_url = string.Empty;

        string m_book_id = string.Empty;

        int m_site_id = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            m_book_id = Request["bookId"];

            if (!int.TryParse(Request["siteId"], out m_site_id))
                m_site_id = 0;

            m_book_name = Request["b"];
            m_author_name = Request["a"];

            BindChapter();

            this.Title = string.Format("体验码_{0}_{1}最新章节列表_来自{2}", m_book_name, m_author_name,m_site_name);

        }

        private void BindChapter()
        {
            try
            {

                BookManager t_book_mgr = new BookManager();

                DataSet t_ds = t_book_mgr.GetBookChapter(m_book_id, m_site_id);

                m_site_name = Consts.GetSiteName(m_site_id);

                if (t_ds != null && t_ds.Tables[0].Rows.Count > 0)
                {
                    rptChapter.DataSource = t_ds.Tables[0];
                    rptChapter.DataBind();
                }

            }
            catch (Exception ex)
            {
                LogHelper.Error("绑定章节列表失败" + ex.ToString());
            }
        }
    }
}
